<template>
  <div>
    <Comp2
      name="无忌"
      :score="score"
      @change-score="handleScore"
      ref="myComp"
    />
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import Comp2 from "./comp2.vue";
const score = ref<number>(50);
interface StuArg {
  msg: string;
  n: number;
}
const handleScore = (obj: StuArg) => {
  score.value += obj.n;
};

// 使用ref属性跟组件绑定
const myComp = ref<InstanceType<typeof Comp2>>();
onMounted(() => {
  console.log(myComp.value);
});
</script>

<style scoped></style>
